package net.starwifi.duobao.entity;

import com.fasterxml.jackson.annotation.JsonProperty;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.Digits;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;

/**
 * 账户交易记录（账户余额变更记录）
 * Created by Administrator on 2015/9/28.
 */
@Entity
@Table(name = "duob_trade_record")
@SequenceGenerator(name = "sequenceGenerator", sequenceName = "duob_trade_record_sequence")
public class TradeRecord extends BaseEntity {


    /** 序号 */
    private String sn;

    /** 0支出，1收入 */
    public int type;

    /** 变动金额 */
    private BigDecimal fee;

    /** 当前余额 */
    private BigDecimal balance;

    /** 备注 */
    private String remarks;

    /** 用户ID*/
    private Long memberId;

    private  String mobile;

    /* 业务分类 （0充值，1转账(红包)，2购物，3理财，4退款）*/
    private int tradeCat;

    /** 关联的订单 */
    private String outSn;

    public TradeRecord(String sn, int type, BigDecimal fee, String remarks, Long memberId) {
        this.sn = sn;
        this.type = type;
        this.fee = fee;
        this.remarks = remarks;
        this.memberId = memberId;
    }

    public TradeRecord() {
    }

    @Column(name = "trade_sn")
    @JsonProperty
    public String getSn() {
        return sn;
    }

    public void setSn(String sn) {
        this.sn = sn;
    }

    @Column(name = "trade_type")
    @JsonProperty
    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    @JsonProperty
    @NotNull(groups = Save.class)
    @Min(0)
    @Digits(integer = 12, fraction = 3)
    @Column(nullable = false, precision = 27, scale = 12)
    public BigDecimal getFee() {
        return fee;
    }

    public void setFee(BigDecimal fee) {
        this.fee = fee;
    }


    @JsonProperty
    @NotNull(groups = Save.class)
    @Min(0)
    @Digits(integer = 12, fraction = 3)
    @Column(nullable = false, precision = 27, scale = 12)
    public BigDecimal getBalance() {
        return balance;
    }

    public void setBalance(BigDecimal balance) {
        this.balance = balance;
    }

    @Column
    @JsonProperty
    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    @Column
    @JsonProperty
    public Long getMemberId() {
        return memberId;
    }

    public void setMemberId(Long memberId) {
        this.memberId = memberId;
    }

    @Column
    @JsonProperty
    public int getTradeCat() {
        return tradeCat;
    }

    public void setTradeCat(int tradeCat) {
        this.tradeCat = tradeCat;
    }

    @Column
    @JsonProperty
    public String getOutSn() {
        return outSn;
    }

    public void setOutSn(String outSn) {
        this.outSn = outSn;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
}
